﻿namespace App_1.ResponseType.DataShaping
{
    public static class DataShaperExentensions
    {
        /// <summary>
        /// 数据构型扩展方法
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="sources"></param>
        /// <param name="fileds"></param>
        /// <returns></returns>
        public static IEnumerable<dynamic> ShapeData<T>(this IEnumerable<T> sources, string? fileds)
        {
            var dataShaper = new DataShaper<T>(fileds);
            return dataShaper.FetchData(sources);
        }

        public static dynamic ShapeData<T>(this T source, string? fileds)
        {
            var dataShaper = new DataShaper<T>(fileds);
            return dataShaper.FetchData(source);
        }
    }
}
